package com.github.shuaidd.rest.runtime;

import org.activiti.app.model.common.ResultListDataRepresentation;
import org.activiti.app.model.runtime.CommentRepresentation;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("app")
public class CommentsResource extends AbstractCommentsResource {

    @Override
    @RequestMapping(value = "/rest/tasks/{taskId}/comments", method = RequestMethod.GET, produces = "application/json")
    public ResultListDataRepresentation getTaskComments(@PathVariable("taskId") String taskId,
                                                        @RequestParam(value = "latestFirst", required = false) Boolean latestFirst) {

        return super.getTaskComments(taskId, latestFirst);
    }

    @Override
    @RequestMapping(value = "/rest/tasks/{taskId}/comments", method = RequestMethod.POST, produces = "application/json")
    public CommentRepresentation addTaskComment(@RequestBody CommentRepresentation commentRequest,
                                                @PathVariable("taskId") String taskId) {

        return super.addTaskComment(commentRequest, taskId);
    }

    @Override
    @RequestMapping(value = "/rest/process-instances/{processInstanceId}/comments", method = RequestMethod.GET, produces = "application/json")
    public ResultListDataRepresentation getProcessInstanceComments(@PathVariable("processInstanceId") String processInstanceId,
                                                                   @RequestParam(value = "latestFirst", required = false) Boolean latestFirst) {

        return super.getProcessInstanceComments(processInstanceId, latestFirst);
    }

    @Override
    @RequestMapping(value = "/rest/process-instances/{processInstanceId}/comments", method = RequestMethod.POST, produces = "application/json")
    public CommentRepresentation addProcessInstanceComment(@RequestBody CommentRepresentation commentRequest,
                                                           @PathVariable("processInstanceId") String processInstanceId) {

        return super.addProcessInstanceComment(commentRequest, processInstanceId);
    }

}
